using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Evolution.Engine.Objects;
using Microsoft.Xna.Framework;

namespace Evolution.Engine.Managers
{
    public class MouseManager : Singleton<MouseManager>
    {
        private Texture2d _Image;
        private Texture2d _AttachedImage;
        private string _Current;

        public string Current { get { return _Current; } set { _Current = value; } }
        public Texture2d AttachedImage { get { return _AttachedImage; } set { _AttachedImage = value; } }
        public Texture2d Image { get { return _Image; } set { _Image = value; } }

        public MouseManager()
        {
            SetMousePointer("Content/GUI/Mouse/MousePointer");
            //SetAttachedPointer("Content/GUI/Mouse/AttachTest");
        }

        public void SetMousePointer(string image)
        {
            if (_Current != image)
            {
                _Image = new Texture2d(InputManager.Instance.CurrentMouseLocation, new Vector2(32, 32), image);
                _Image.LoadContent();
                _Current = image;
            }
        }

        public void SetAttachedPointer(string image)
        {
            if (string.IsNullOrEmpty(image))
                _AttachedImage = null;
            else
            {
                _AttachedImage = new Texture2d(_Image.Position + _Image.Size, new Vector2(16, 16), image);
                _AttachedImage.LoadContent();
            }
        }

        public void Update(GameTime gameTime)
        {
            _Image.Position = InputManager.Instance.CurrentMouseLocation;
            if (_AttachedImage != null) _AttachedImage.Position = _Image.Position + _Image.Size;
        }

        public void Draw(GameTime gameTime)
        {
            _Image.Draw(gameTime);
            if (_AttachedImage != null) _AttachedImage.Draw(gameTime);
        }
    }
}
